<?php

/*
Scheduled Tasks (admin_tasks.php)
*/

$page_title = "Scheduled Tasks";
$rank_check = 7;
include "../header.inc.php";

print "$openHTML";

$game=$_GET['game'];
$act=$_GET['act'];
$task=$_GET['task'];

if($act=="edit")
{
	$getTasks = fetch("Select * from ghetto_cron where game = '$game' and id= '$task'");
	$_POST["task_type"] = $getTasks['cron_name'];
	
	$explodeCronTime = explode(":", $getTasks['cron_time']);
	$cronHour  = $explodeCronTime[0];
	$cronMin   = $explodeCronTime[1];
	if ($cronHour > 12) { $cronAMPM = 12; $cronHour -= 12; } else { $cronAMPM = 0; }

	$_POST["task_hour"] = $cronHour;
	$_POST["task_minutes"] = $cronMin;
	$_POST["am_pm"] = $cronAMPM;
	$_POST["monthly_run"] = $getTasks['monthly_run'];
	$_POST["weekly_run"] = $getTasks['weekly_run'];
	$_POST["add_update"] = $getTasks['add_update'];

	$select[0] = "";
	$select[1] = "";
	$select[2] = "";
	$select[3] = "";
	$select[4] = "";
	$select[5] = "";
	$select[5] = "";
	$select[6] = "";
	$select[7] = "";
	$select[8] = "";

	switch ($getTasks['cron_name'])
	{
		case "Low Stock":
		{
			$select[0] = " SELECTED ";
			break;
		}
		case "Medium Stock":
		{
			$select[1] = " SELECTED ";
			break;
		}
		case "Full Stock":
		{
			$select[2] = " SELECTED ";
			break;
		}
		case "Lower Pet Attitude":
		{
			$select[3] = " SELECTED ";
			break;
		}
		case "Lower Pet Hunger":
		{
			$select[4] = " SELECTED ";
			break;
		}
		case "Lower User Hunger":
		{
			$select[5] = " SELECTED ";
			break;
		}
		case "End Penny Play":
		{
			$select[6] = " SELECTED ";
			break;
		}
		case "End Referral Contest":
		{
			$select[7] = " SELECTED ";
			break;
		}
		case "End Daily Lotto":
		{
			$select[8] = " SELECTED ";
			break;
		}
	}

	$task_hour = $cronHour;
	$task_minutes = $cronMin;
	$am_pm = $cronAMPM;
	$monthly_run = $getTasks['monthly_run'];
	$weekly_run = $getTasks['weekly_run'];
	$add_update = $getTasks['add_update'];
	
	$select[$getTasks['cron_name']] = " SELECTED";
	$select_ampm[$cronAMPM] = " SELECTED ";
	$select_monthly_run[$_POST["monthly_run"]] = " SELECTED ";
	$select_weekly_run[$weekly_run] = " SELECTED ";
	
}
ECHO <<<END

<FORM ACTION="admin_edit_tasks.pro.php?game=$game&act=edit&task=$task" METHOD=POST>

<p><b>EDIT A TASK:</b></p>

<p>Edit Task Type: <select name=task_type>
<option value="Low Stock" $select[0] >Low Shop Stock
<option value="Medium Stock" $select[1] >Medium Shop Stock
<option value="Full Stock" $select[2] >Full Shop Stock
<option value="Lower Pet Attitude" $select[3] >Lower Pet Attitude
<option value="Lower Pet Hunger" $select[4] >Lower Pet Hunger
<option value="Lower User Hunger" $select[5] >Lower User Hunger
<option value="End Penny Play" $select[6] >End Penny Play
<option value="End Referral Contest" $select[7] >End Referral Contest
<option value="End Daily Lotto" $select[8] >End Daily Lotto
</select><br>
Run it at: <input type=text name=task_hour size=5 value=$task_hour >:<input type=text name=task_minutes size=5 value=$task_minutes ><select name=am_pm><option value="0" $select_ampm[0] >A. M.<option value="12" $select_ampm[12] >P. M.</select><br>
ONLY Run on the <select name=monthly_run>
<option value=0 $select_monthly_run[0]>None
<option value=1 $select_monthly_run[1]>1st
<option value=2 $select_monthly_run[2]>2nd
<option value=3 $select_monthly_run[3]>3rd
<option value=4 $select_monthly_run[4]>4th
<option value=5 $select_monthly_run[5]>5th
<option value=6 $select_monthly_run[6]>6th
<option value=7 $select_monthly_run[7]>7th
<option value=8 $select_monthly_run[8]>8th
<option value=9 $select_monthly_run[9]>9th
<option value=10 $select_monthly_run[10]>10th
<option value=11 $select_monthly_run[11]>11th
<option value=12 $select_monthly_run[12]>12th
<option value=13 $select_monthly_run[13]>13th
<option value=14 $select_monthly_run[14]>14th
<option value=15 $select_monthly_run[15]>15th
<option value=16 $select_monthly_run[16]>16th
<option value=17 $select_monthly_run[17]>17th
<option value=18 $select_monthly_run[18]>18th
<option value=19 $select_monthly_run[19]>19th
<option value=20 $select_monthly_run[20]>20th
<option value=21 $select_monthly_run[21]>21st
<option value=22 $select_monthly_run[22]>22nd
<option value=23 $select_monthly_run[23]>23rd
<option value=24 $select_monthly_run[24]>24th
<option value=25 $select_monthly_run[25]>25th
<option value=26 $select_monthly_run[26]>26th
<option value=27 $select_monthly_run[27]>27th
<option value=28 $select_monthly_run[28]>28th
<option value=29 $select_monthly_run[29]>29th
<option value=30 $select_monthly_run[30]>30th
<option value=31 $select_monthly_run[31]>31st
</select> of the month. (optional for monthly runs)<br>
ONLY Run on <select name=weekly_run>
<option value=0 $select_weekly_run[0]>None
<option value=1 $select_weekly_run[1]>Sundays
<option value=2 $select_weekly_run[2]>Mondays
<option value=3 $select_weekly_run[3]>Tuesdays
<option value=4 $select_weekly_run[4]>Wednesdays
<option value=5 $select_weekly_run[5]>Thursdays
<option value=6 $select_weekly_run[6]>Fridays
<option value=7 $select_weekly_run[7]>Saturdays
</select> (optional for weekly runs)<br>
Add this Update: (only fill out if you want it to add an update.)<Br>
<TEXTAREA NAME=add_update ROWS=7 COLS=27 WRAP=virtual>$add_update</TEXTAREA><br>
<input type=submit value="Edit Task">

</FORM>

END;

print "$closeHTML";
?>
